<CFIF lPreProcessShowMsg EQ "Yes">
<table border=0 cellpadding="1px" cellspacing=0 width="100%">
</CFIF>
<CFQUERY NAME="getSubcompany" DATASOURCE="#client.global_dsn#">
	SELECT A.IBOSEDSN
	FROM GRGDATALOCATION A, GRGSUBCOMPANY B
	WHERE B.SUBCOMPANYCODE='#GetEntry.SUBCOMPANYCODE#' AND A.DATALOCATIONCODE=B.DATALOCATIONCODE
</CFQUERY>
<CFSET theSubCompany="#getSubcompany.IBOSEDSN#">
<CFQUERY NAME="qryPersonnelID" DATASOURCE=#theSubCompany#>
	SELECT DISTINCT PERSONNELIDNO, DOCNUMBER
	FROM         SINMOVEMENTEMPS
	WHERE     (DOCNUMBER = '#GETENTRY.DOCNUMBER#')
</CFQUERY>
<CFOUTPUT>
<CFIF qryPersonnelID.RECORDCOUNT>
	<CFLOOP QUERY="qryPersonnelID">
		<CFQUERY NAME="qryHistory" DATASOURCE=#client.company_dsn#>
			SELECT TOP 1 ITEMCODE,ORIGINALVALUE,NEWVALUE,EFFECTIVEDATE
			FROM       CINMOVEMENTHIST
			WHERE     (PERSONNELIDNO = '#qryPersonnelID.PERSONNELIDNO#')
			ORDER BY EFFECTIVEDATE DESC
		</CFQUERY>
		<CFQUERY NAME="qryCMFPA" DATASOURCE=#client.company_dsn#>
			SELECT PERSONNELIDNO,FIRSTNAME,LASTNAME,MIDDLENAME
			FROM         CMFPA
			WHERE     (PERSONNELIDNO = '#qryPersonnelID.PERSONNELIDNO#')
		</CFQUERY>
		<CFIF qryHistory.RECORDCOUNT>
			<CFIF lPreProcessShowMsg EQ "Yes">
				<tr>
					<td>
						<table border=0 cellpadding=2 cellspacing=0 width="100%">
						<tr>
							<td nowrap>Personnel ID No.&nbsp;</td>
							<td nowrap width="100%" class="bold">#qryCMFPA.PERSONNELIDNO#</td>
						</tr>
						<tr>
							<td nowrap>Last Name&nbsp;</td>
							<td nowrap width="100%" class="bold">#qryCMFPA.LASTNAME#</td>
						</tr>
						<tr>
							<td nowrap>First Name&nbsp;</td>
							<td nowrap width="100%" class="bold">#qryCMFPA.FIRSTNAME#</td>
						</tr>
						<tr>
							<td nowrap>Middle Name&nbsp;</td>
							<td nowrap width="100%" class="bold">#qryCMFPA.MIDDLENAME#</td>
						</tr>
						</table>
					</td>
					<td bgcolor="##808080"></td>
			</CFIF>
			<CFQUERY NAME="qryLastHistory" DATASOURCE=#client.company_dsn#>
				SELECT ITEMCODE,ORIGINALVALUE,NEWVALUE,EFFECTIVEDATE
				FROM         CINMOVEMENTHIST
				WHERE     (PERSONNELIDNO = '#qryPersonnelID.PERSONNELIDNO#')
					AND EFFECTIVEDATE='#qryHistory.EFFECTIVEDATE#'
				ORDER BY EFFECTIVEDATE DESC
			</CFQUERY>
			<CFLOOP QUERY="qryLastHistory">
				<CFQUERY NAME="qryItemDescription" DATASOURCE=#client.global_dsn#>
					SELECT DESCRIPTION
					FROM        GLKMOVEITEMS
					WHERE    ITEMCODE='#qryLastHistory.ITEMCODE#'
				</CFQUERY>
				<CFIF lPreProcessShowMsg EQ "Yes">
					<td>
						<table border=0 cellpadding=2 cellspacing=0 width="100%">
						<tr>
							<td nowrap>Item&nbsp;</td>
							<td nowrap width="100%" class="bold"><CFIF qryItemDescription.DESCRIPTION NEQ "|NULL|" AND qryItemDescription.DESCRIPTION NEQ "">#qryItemDescription.DESCRIPTION#<CFELSE>#qryLastHistory.ITEMCODE#</CFIF></td>
						</tr>
						<tr>
							<td nowrap>New Value&nbsp;</td>
							<td nowrap width="100%" class="bold">#qryLastHistory.NEWVALUE#</td>
						</tr>
						<tr>
							<td nowrap>Old Value&nbsp;</td>
							<td nowrap width="100%" class="bold">#qryLastHistory.ORIGINALVALUE#</td>
						</tr>
						<tr>
							<td nowrap>Effectivity Date&nbsp;</td>
							<td nowrap width="100%" class="bold">#DateFormat(qryLastHistory.EFFECTIVEDATE, "mm/dd/yyyy")#</td>
						</tr>
						</table>
					</td>
					<td bgcolor="##808080"></td>
				</CFIF>
			</CFLOOP>
			</tr>
		<CFELSE>
			<CFIF lPreProcessShowMsg EQ "Yes">
			<tr><td nowrap class="bold">No Movement History for #qryCMFPA.LASTNAME#,#qryCMFPA.FIRSTNAME# #qryCMFPA.MIDDLENAME# </td></tr>
			</CFIF>
		</CFIF>
	</CFLOOP>
</CFIF>
</CFOUTPUT>
<CFIF lPreProcessShowMsg EQ "Yes">
</table>
</CFIF>
<CFSET lPreProcessValidated="Yes">



